package cn.isjinhao.se.sql.grammar.statement.create.represention;

import cn.isjinhao.se.sql.grammar.CurdStatement;
import cn.isjinhao.se.sql.grammar.CurdStatementVisitor;
import cn.isjinhao.se.sql.grammar.statement.create.InsertType;
import cn.isjinhao.se.sql.grammar.statement.create.SingleInsertMetaInfo;
import cn.isjinhao.se.sql.lexical.token.Token;

/**
 * @Author ISJINHAO
 * @Date 2021/4/5 21:00
 */
public class Insert extends CurdStatement {

    private InsertType insertType;

    private SingleInsertMetaInfo singleInsertMetaInfo;

    private Token constrict;

    private CurdStatement onDuplicateUpdate;

    private Token operator;

    private CurdStatement curdStatement;

    /**
     * @param constrict
     * @param operator          tableName
     * @param curdStatement     valuesRep
     */
    public Insert(Token constrict, Token operator, CurdStatement curdStatement) {
        this.operator = operator;
        this.curdStatement = curdStatement;
        this.constrict = constrict;
    }

    /**
     *
     * @param constrict
     * @param operator          tableName
     * @param curdStatement     valuesRep
     * @param onDuplicateUpdate
     */
    public Insert(Token constrict, Token operator, CurdStatement curdStatement, CurdStatement onDuplicateUpdate, InsertType insertType) {
        this.operator = operator;
        this.curdStatement = curdStatement;
        this.constrict = constrict;
        this.onDuplicateUpdate = onDuplicateUpdate;
        this.insertType = insertType;
    }

    @Override
    public <R> R accept(CurdStatementVisitor<R> curdStatementVisitor) {
        return curdStatementVisitor.visitInsert(this);
    }

    public Token getConstrict() {
        return constrict;
    }

    public CurdStatement getOnDuplicateUpdate() {
        return onDuplicateUpdate;
    }

    public SingleInsertMetaInfo getSingleInsertMetaInfo() {
        return singleInsertMetaInfo;
    }

    public void setSingleInsertMetaInfo(SingleInsertMetaInfo singleInsertMetaInfo) {
        this.singleInsertMetaInfo = singleInsertMetaInfo;
    }

    public Token getOperator() {
        return operator;
    }

    public CurdStatement getCurdStatement() {
        return curdStatement;
    }

    public InsertType getInsertType() {
        return insertType;
    }

}
